﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Omu.AwesomeMvc;
using MvcApplication4.Models;

namespace MvcApplication4.Controllers
{
    public class UBSAjaxDropdownController : Controller
    {
        private readonly BD_Vacinas2Context _db = new BD_Vacinas2Context();

        public ActionResult GetItems(int? v, int? parent)
        {
            var tempdata = TempData["tempfun"] as int?;
            tb_Funcionario tbfuncionario = _db.tb_Funcionario.Find(parent);

            //return Json(new SelectableItem(tbfuncionario.ID_UBS, tbfuncionario.tb_UBS.Nome_UBS));

            return Json(_db.tb_Funcionario.Where(o => o.ID_Funcionario == parent).ToList()
                            .Select(o => new SelectableItem(o.ID_UBS, o.tb_UBS.Nome_UBS)));// key, text, selected
        }

    }
}
